//
//  LJM_SouSuo_ViewController.m
//  wind
//
//  Created by 李金明 on 16/1/21.
//  Copyright © 2016年 李金明. All rights reserved.
//

#import "LJM_SouSuo_ViewController.h"
#import "LJM_SearchBar.h"
@interface LJM_SouSuo_ViewController () <UISearchBarDelegate>
@property (nonatomic, retain) UIButton *bactButton;
@property (nonatomic, retain) UIView *barview;
@property (nonatomic, retain) LJM_SearchBar *searchBar;
@end

@implementation LJM_SouSuo_ViewController
- (void)dealloc
{
    self.backDelegate = nil;
    [_searchBar release];
    [_bactButton release];
    [_barview release];
    [super dealloc];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    [self navigationBarView];
}
#pragma 自定义navigationBar
- (void)navigationBarView
{
    
    self.barview = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, NAVIGATIONBARHEIGHT)];
    self.barview.userInteractionEnabled = YES;
    self.barview.backgroundColor = [UIColor colorWithRed:69 / 255.0 green:175 / 255.0 blue:248 / 255.0 alpha:1.0];
    [self.navigationController.navigationBar addSubview:self.barview];
    [_barview release];
    self.bactButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.bactButton setTitle:@"返回" forState:UIControlStateNormal];
    [self.bactButton addTarget:self action:@selector(backButton) forControlEvents:UIControlEventTouchUpInside];
    [self.bactButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [self.barview addSubview:self.bactButton];
    [self.bactButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.barview.mas_left).offset(10);
        make.width.mas_equalTo(@50);
        make.bottom.equalTo(self.barview.mas_bottom).offset(-5);
        make.height.mas_equalTo(@30);
    }];
    
    self.searchBar = [[LJM_SearchBar alloc] initWithFrame:CGRectZero];
    self.searchBar.placeholder = @"搜搜呀";
    self.searchBar.delegate = self;
    [self.barview addSubview:self.searchBar];
    //隐藏背景
    [self.searchBar setBackgroundImage:[UIImage new]];
    [self.searchBar setTranslucent:YES];
    [self.searchBar mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.bactButton.mas_right).offset(10);
        make.right.equalTo(self.barview.mas_right).offset(-10);
        make.height.equalTo(self.bactButton.mas_width);
        make.bottom.equalTo(self.barview.mas_bottom).offset(5);
    }];
    [_searchBar release];
    

    
    
}
#pragma searchBar的协议方法 当点搜索的时候
- (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar
{
    NSLog(@"%@", self.searchBar.text);
}
#pragma searchBar的协议方法
- (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText
{
    NSLog(@"%@", searchText);
    
    
    
    
}
#pragma 返回的动作
- (void)backButton
{
    [self.navigationController popViewControllerAnimated:YES];
    [self.barview removeFromSuperview];
    [self.backDelegate backSousuoVCAction];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
